def print_file_info(file_name):
    """
    将给定路径的文件内容输出到控制台
    :param file_name:即将读取的文件路径
    :return:none
    """
    f = None
    try:
        f = open(file_name, "r", encoding="UTF-8")
        content = f.read()
        print("文件全部内容如下：")
        print(content)
    except Exception as e:
        print(f"出现异常了，原因是：{e}")
    finally:
        if f:
            f.close()

def append_to_file(file_name,data):
    """
    将制定的内容写入到指定的文件中
    :param file_name:指定文件路径
    :param data:指定数据
    :return:none
    """
    f = open(file_name, "a", encoding="UTF-8")
    f.write(data)
    f.write("\n")
    f.close()


if __name__ == '__main__':
    # print_file_info("E:/桌面/Python/基础/模块/my_utils/abc.txt")
    append_to_file("//基础/模块/my_utils/abc.txt", "学习Python")